const fs = require('fs');
const path = require('path');
const server = require('./server');
const configPath = path.join(__dirname, '../config.json');
const { log } = require('./log-utils');

// 读取配置文件  
fs.readFile(configPath, (err, data) => {
  if (err) {
    log('error', `Failed to read config file: ${configPath}`);
    process.exit(1);
  }

  const config = JSON.parse(data);
  const port = config.port || 3000;

  // 启动服务器  
  server.start(port, config.scripts);
});